package com.gan.simple_init.easyexcel;

import com.alibaba.excel.EasyExcel;
import com.gan.simple_init.model.movie.dto.AddMovieDto;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;
import java.util.Map;

/**
 * @author gan
 * @date 2023/10/25 20:01
 */
@SpringBootTest
public class read {

    /**
     * 同步无监听器读取Excel
     */
    @Test
    void readSyncObj(){
        String fileName = "D:\\项目\\simple-init\\doc\\电影信息.xlsx";
        List<AddMovieDto> movieDtoList =
                EasyExcel.read(fileName).head(AddMovieDto.class).sheet(0).doReadSync();
        for (AddMovieDto movieDto : movieDtoList) {
            System.out.println(movieDto);
        }
    }

    /**
     * 同步无监听器读取Excel
     */
    @Test
    void readSyncMap(){
        String fileName = "D:\\项目\\simple-init\\doc\\电影信息.xlsx";
        List<Map<Integer,Object>> movieDtoList =
                EasyExcel.read(fileName).sheet(0).doReadSync();
        for (Map<Integer,Object> map :movieDtoList) {
            System.out.println(map.get(0));
        }
    }

}
